{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <!-- 表单头部 -->
                <div class="box-header with-border">
                    <div class="btn-group">

                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post"
                      enctype="multipart/form-data">
                    <!-- 表单字段区域 -->
                    <div class="box-body">

                        {foreach name='data' id='item' key='data_key'}
                        {if $item.config_input == 'text'}

                        <div class="form-group">
                            <label style="width: 36%;" for="{$item.config_key}" class="col-sm-2 control-label">{$item.config_remarks}</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="{$item.config_key}"  name="{$item.config_key}" value="{$item.config_value}" type="text" class="form-control field-text">
                            </div>
                        </div>

                        {elseif $item.config_input == 'number'}

                        <div class="form-group">
                            <label style="width: 36%;" for="{$item.config_key}" class="col-sm-2 control-label">{$item.config_remarks}</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="{$item.config_key}"  name="{$item.config_key}" value="{$item.config_value}" type="number" class="form-control field-text">
                            </div>
                        </div>

                        {elseif $item.config_input == 'textarea'}

                        <div class="form-group">
                            <label style="width: 36%;" for="{$item.config_key}" class="col-sm-2 control-label">{$item.config_remarks}</label>
                            <div class="col-sm-10 col-md-4">
                                <textarea id="{$item.config_key}" name="{$item.config_key}" type="text/plain" style="height: 80px;width: 100%;">{$item.config_value|raw|default=''}</textarea>
                            </div>
                        </div>

                        {elseif $item.config_input == 'select'}

                        <div class="form-group">
                            <label style="width: 36%;" for="{$item.config_key}" class="col-sm-2 control-label">{$item.config_remarks}</label>
                            <div class="col-sm-10 col-md-4">
                                <select name="{$item.config_key}" id="{$item.config_key}" class="form-control field-select">
                                    <option value="1" {if isset($item) && $item.config_value==1}selected{/if}>开启</option>
                                    <option value="2" {if isset($item) && $item.config_value==2}selected{/if}>关闭</option>
                                </select>
                            </div>
                        </div>

                        {elseif $item.config_input == 'img'}

                        <div class="form-group">
                            <label style="width: 36%;" for="{$item.config_key}" class="col-sm-2 control-label">{$item.config_remarks}</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="{$item.config_key}" name="{$item.config_key}" placeholder="请上传图片"
                                       data-initial-preview="{$item.config_value|default=''}" type="file"
                                       class="form-control field-image">
                            </div>
                        </div>
                        <script>
                            $('#{$item.config_key}').fileinput({
                                language: 'zh',
                                overwriteInitial: true,
                                browseLabel: '浏览',
                                initialPreviewAsData: true,
                                dropZoneEnabled: false,
                                showUpload: false,
                                showRemove: false,
                                allowedFileTypes: ['image'],
                                maxFileSize: 10240,
                            });
                        </script>


                        {/if}
                        {/foreach}


                        <input type="hidden" name="edit_config" value="edit_config">
                    </div>
                    <!-- 表单底部 -->
                    <div class="box-footer">
                        <div class="col-sm-2" style="width: 36%;">
                        </div>
                        <div class="col-sm-10 col-md-4">
                            <div class="btn-group">
                                <button type="submit" class="btn flat btn-info dataFormSubmit">
                                    确认更新配置
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<script>
    /** 表单验证 **/
    $('#dataForm').validate({
        rules: {
            'customerservicephone': {
                required: true,
            },
        },
        messages: {
            'customerservicephone': {
                required: '请填写完整信息',
            },
        }
    });
</script>
{/block}